package com.lxs.legou.order.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;

/**
 * @Auther: Mcb
 * @Date: 2022/2/10 00:01
 * @Description: 消费端确认机制监听类,spring环境使用
 */
public class AckListener implements ChannelAwareMessageListener {

    /**
     * Consumer ACK机制：
     * 1. 设置手动签收。acknowledge="manual"
     * 2. 让监听器类实现ChannelAwareMessageListener接口
     * 3. 如果消息成功处理，则调用channel的 basicAck()签收
     * 4. 如果消息处理失败，则调用channel的basicNack()拒绝签收，broker重新发送给consumer
     */
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {

    }
}
